﻿using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Dynamic;
using Fuse8.DomainFramework.Domain;

namespace Fuse8.ContentManagementFramework.Domain
{
    [Serializable]
    public class GenericCmsEntity : IGenericCmsEntity, IEntityObject<int>
    {
        public Dictionary<string, object> Values { get; private set; }

        public GenericCmsEntity()
        {
            Values = new Dictionary<string, object>();
        }

        public string TypeParameter { get { return "GenericCmsEntity"; } }
        public string EntityIdentfier { get { return Id.ToString(); } }
        public bool IsNew { get { return Id == 0; } }
        public bool IsCreated { get { return Id > 0; } }
        public bool Equals(IEntityObject<int> x, IEntityObject<int> y)
        {
            return x.Id.Equals(y.Id);
        }

        public int GetHashCode(IEntityObject<int> obj)
        {
            return obj.Id.GetHashCode();
        }

        public void IncreaseId()
        {
            
        }

        public int Id { get; set; }

        public object this[string key]
        {
            get
            {
                if (Values.ContainsKey(key))
                {
                    return Values[key];
                }

                return null;
            }
            set { Values[key] = value; }
        }

        public void Add(string key, object value)
        {
            Values.Add(key, value);
        }
    }

    public interface IGenericCmsEntity
    {
        object this[string key] { get; set; }
        void Add(string key, object value);
    }
}